<!DOCTYPE html>
<html>
<body>
  <form id="uploadForm">
    <input type="file" id="imageInput" accept="image/*">
    <button type="submit">分类垃圾</button>
  </form>
  <div id="result"></div>

  <script>
    document.getElementById('uploadForm').addEventListener('submit', async (e) => {
      e.preventDefault();
      const formData = new FormData();
      formData.append('image', document.getElementById('imageInput').files[0]);

      const response = await fetch('/classify', {
        method: 'POST',
        body: formData
      });
      const data = await response.json();
      document.getElementById('result').innerText = `分类结果: ${data.class}`;
    });
  </script>
</body>
</html>